#!/bin/bash -f

function Usage {
    echo "Usage: $0 [-h] [-m]"
    echo "               No params for kernel compilation only"
    echo " -m (optional) To compile the modules too"
    echo " -h (optional) To print this help menu"
    echo " Only one parameter is allowed"
    exit
}

if [ "$#" -gt "1" ]; then
  Usage
fi

if [ "$#" -gt "0" ]; then
  if [ "$1" = "-h" ]; then
    Usage
  elif [ "$1" = "-m" ]; then
    echo "Compiling with Modules."
  else
    echo -e "Illegal parameter!!!\n"
    Usage
  fi
fi

cd /usr/src/linux-2.4.18-14custom
svn update .
make bzImage

if [ "$#" -gt "0" ]; then
  if [ "$1" = "-m" ]; then
    make modules
    make modules_install
  fi
fi

cp -f arch/i386/boot/bzImage /boot/vmlinuz-2.4.18-14custom
cd /boot
mkinitrd -f 2.4.18-14custom.img 2.4.18-14custom
